﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
public partial class hoadon : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btthem_Click(object sender, EventArgs e)
    {
        String s="<Hoadon mahoadon=\"1\" makhach=\"long\" sotien=\"134\" soluong=\"3\" Ma_nhan_vien=\"nv01\">";
		String s1="<Chitiet>";
		String s2="<Vattu mavt=\"2\" soluong=\"2\" dongia=\"343\" tien=\"34\"></Vattu>";
        s=s+s1+s2;
            s2="<Vattu mavt=\"1\" soluong=\"2\" dongia=\"343\" tien=\"34\"></Vattu>";
            s=s+s2;
            s2="<Vattu mavt=\"1\" soluong=\"2\" dongia=\"343\" tien=\"34\"></Vattu>";
            s=s+s2;
            s2 = "</Chitiet></Hoadon>";
            s = s + s2;
        dataservice data=new dataservice();
        SqlConnection conn = data.getconnect();
        SqlCommand cmd = new SqlCommand("sp_tbl_hoa_don_insert", conn);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.Add(new SqlParameter("@doc",s));
        cmd.ExecuteNonQuery();
        conn.Close();

    }
    protected void btsua_Click(object sender, EventArgs e)
    {
        String s = "<Hoadon mahoadon=\"1\" makhach=\"long\" sotien=\"134\" soluong=\"3\" Ma_nhan_vien=\"nv01\">";
        String s1 = "<Chitiet>";
        String s2 = "<Vattu mavt=\"2\" soluong=\"2\" dongia=\"343\" tien=\"34\"></Vattu>";
        s = s + s1 + s2;
        s2 = "<Vattu mavt=\"1\" soluong=\"2\" dongia=\"343\" tien=\"34\"></Vattu>";
        s = s + s2;
        s2 = "<Vattu mavt=\"1\" soluong=\"2\" dongia=\"343\" tien=\"34\"></Vattu>";
        s = s + s2;
        s2 = "</Chitiet></Hoadon>";
        s = s + s2;
        dataservice data = new dataservice();
        SqlConnection conn = data.getconnect();
        SqlCommand cmd = new SqlCommand("sp_tbl_hoa_don_insert", conn);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.Add(new SqlParameter("@doc", s));
        cmd.ExecuteNonQuery();
        conn.Close();
    }
    protected void btxoa_Click(object sender, EventArgs e)
    {
        String s = "<Hoadon mahoadon=\"1\"></Hoadon>";
        dataservice data = new dataservice();
        SqlConnection conn = data.getconnect();
        SqlCommand cmd = new SqlCommand("sp_tbl_hoa_don_delete", conn);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.Add(new SqlParameter("@doc", s));
        cmd.ExecuteNonQuery();
        conn.Close();
    }
    protected void btlaychuoi_Click(object sender, EventArgs e)
    {
        dataservice data = new dataservice();
        SqlConnection conn = data.getconnect();
        SqlCommand cmd = new SqlCommand("sp_test_lay_chuoi", conn);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.Add(new SqlParameter("@a", SqlDbType.VarChar));
        //dinh nghia @a la tham so tra ve cua ham
        cmd.Parameters["@a"].Direction = ParameterDirection.ReturnValue;
       cmd.ExecuteNonQuery();
        String s= cmd.Parameters["@a"].Value.ToString();
        Response.Write(s+"____________________");
        conn.Close();
    }
}